<template>
	<a class="dingwei">
		<image @click="qqs" style="width: 7vw;height: 7vw;" src="../../static/image/QQ.png" mode=""></image>
		<view class="text">
			QQ客服
		</view>
	</a>
</template>

<script>
	export default {
		data() {
			return {
				qqNumber: ""
			}
		},
		mounted() {
			this.getSetting()
		},
		methods: {
			qqs() {
				// 判断是否PC端访问
				var isMobile = /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent);
				if (!isMobile) {
					console.log(isMobile);
					console.log("pcccccc", this.qqNumber);
					// const url = `https://wpa.qq.com/msgrd?v=3&uin=${this.qqNumber}&site=qq&menu=yes`;
					const url = `tencent://AddContact/?fromId=45&fromSubId=1&subcmd=all&uin=${this.qqNumber}`
					console.log(url);
					window.open(url, '_blank')
				} else {
					console.log(isMobile);
					console.log('yd', this.qqNumber);
					const url = `mqqwpa://im/chat?chat_type=wpa&uin=${this.qqNumber}&version=1&src_type=web`;
					window.location.href = url;
				}
			},
			getSetting() {
				uni.request({
					url: "/api/index/getSetting",
					method: "POST"
				}).then(res => {
					this.qqNumber = res.data.data.qq
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.dingwei {
		width: 10vw;
		height: 12vw;
		border-radius: 10rpx;
		// background-color: red transparent;
		background-color: rgba(255, 255, 255, 0.7);
		// background-color:transparent;
		position: fixed;
		padding: 10rpx;
		right: 10rpx;
		bottom: 20vh;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-between;

		.text {
			font-size: 3vw;
			color: black;
			white-space: nowrap;
		}
	}
</style>